import {axios} from '../utils/request'
import {MODEL_MODULE, PREDICTION_MODULE} from "./_prefix";
import {MOCK} from "./_prefix";


/**
 * 使用模型预测 POST /model/use
 * @param modelId
 * @param fileId
 * @returns
 */
export const use = async payload =>{
    const {modelId, fileInfoId, userId}=payload;
    const res=await axios.post(
        `${PREDICTION_MODULE}/predict?modelId=${modelId}&fileInfoId=${fileInfoId}&userId=${userId}`
    );
    // const res=await axios.post(`${MOCK}/ml/predictions/predict:modelId=1&fileInfoId=2`);
    return res;
}
/**
 * 获取某一个模型下的预测结果 GET
 * @param userId
 * @returns
 */
export const getPrediction = async payload => {
    const{ modelId, userId } = payload;
     const res = await axios.get(`${PREDICTION_MODULE}/models/${modelId}`, {params: {userId: userId}})
    // const res = await axios.get(`${MOCK}/ml/predictions/models/:modelId`)
    return res
}


/**
 * 获取某用户的预测结果 GET
 * @param userId
 * @returns
 */
export const getPredictionAll = async payload => {
    const{ userId } = payload;
    const res = await axios.get(`${PREDICTION_MODULE}`, {params: {userId: userId}})
    return res
}


/**
 * 获取预测结果详情 GET
 * @param modelId
 * @returns
 */
export const getPredictionDetail = async payload => {
    const{ predictionId } = payload;
    // const res = await axios.get(`${MODEL_MODULE}/get/all/dl`, {params: {modelId: modelId}})
    const res = await axios.get(`${MOCK}/ml/predictions/:predictionId`)
    return res
}